(function(){const P="[data-product-id][data-product-df-group-leader]:has(.dfd-card-pricing)",f=".dfd-card-pricing",w=".dfd-card-price--sale, :not(:has(.dfd-card-price--sale)) > .dfd-card-price";function p(o,e){const t=o.match(/(.*?)(\d[\d.,\s\u00A0\u202F]*\d|\d)(.*)/);if(!t)return String(e);const[,c,n,d]=t,r=n.match(/([.,])(\d+)$/);let s="",a=0,l=n;if(r){const m=r[2].length,u=n.substring(0,n.length-r[0].length);if(m===3){const S=u.match(/[.,\s\u00A0\u202F]/);S&&S[0]!==r[1]&&(s=r[1],a=3,l=u)}else s=r[1],a=m,l=u}const g=l.match(/[.,\s\u00A0\u202F]/),h=g?g[0]:"",[E,q]=e.toFixed(a).split(".");let i=E;h&&(i=i.replace(/\B(?=(\d{3})+(?!\d))/g,h));const L=a>0?i+s+q:i;return c+L+d}function A(o){const e=Array.from(document.querySelectorAll(P));return o?e.filter(t=>t.hasAttribute(o)):e}function x(o){for(const e of o){const t=e.querySelector(f);t&&t.classList.add("dfd-contextual-price-loading")}}function b(o){for(const e of o){const t=e.querySelector(f);t&&t.classList.remove("dfd-contextual-price-loading")}}function y(o,e){for(const t of o){const c=e[t.dataset.productId];if(c!=null)for(const n of t.querySelectorAll(w))n.textContent=p(n.textContent.trim(),c),n.setAttribute("data-value",c)}}function C(o){let e=null,t=null;const c=["doofinder.layer.load","doofinder.layer.update","doofinder.carousel.load","doofinder.carousel.update","doofinder.quiz.load","doofinder.quiz.update"],n=["doofinder.recommendations-widget.update"],d=r=>{clearTimeout(e),e=setTimeout(()=>{t&&t.abort(),t=new AbortController,o(r,t.signal)},100)};c.forEach(r=>{document.addEventListener(r,()=>d(r))}),n.forEach(r=>{window.addEventListener(r,()=>d(r))})}window.DoofinderContextualPrices={formatPrice:p,getCards:A,hidePrices:x,showPrices:b,updatePrices:y,onUpdate:C}})();